package yt.kpool.base;

import android.content.Context;
import android.os.Build;
import android.os.StrictMode;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;


import org.litepal.LitePalApplication;

import yt.kpool.util.SPUtil;

/**
 * Created by Administrator on 2017/4/21.
 * 整个项目的通用的Application
 */

public class BaseApplication extends LitePalApplication {
    public static final String ISSHOWPWD = "IsShowpwd";//是否显示密码
    public static final String ISLOGIN = "IsLogin";//是否自动登录
    public static final String ID = "id";//本地保存的账号
    public static final String PHONE = "phone";//本地保存的手机账号
    public static final String PWD = "pwd";//本地保存的密码
    public static final String NAME = "name";//本地保存登录人的姓名
    public static final String PHOTOPATH = "photopath";//本地保存登录人的头像
    public static final String MONEYKIND = "moneykind";//钱的币种 1是人民币 2是美元
    public static final String VERSIONCODE = "versioncode";//本地保存apk版本号
    public static final String UPDATEURL = "updateurl";//apk更新地址
    public static final String TOKEN = "token";//存储登录后的Token

    public static String NewToken = "";//新房登录接口获取 除了登录其它接口需要添加的Token
    public static int NewIsLogin = 0;//新房是否登录成功 默认0未成功
    public static Context context;//定义一个静态的全局变量
    public static double Exchange;//定义一个静态的全局变量
    public static final String FILENAME = "fileName";//保存的名称

    public static final String UserLogin = "UserLogin";//登录信息名称
    public static final String TEL = "tel";//存储登录后的手机号
    public static final String PASSWORD = "password";//存储登录后密码
    public static final String UserType = "usertype";//=3时 代理商 5 业务员

    public static final String KEYLOGIN = "keylogin";//快速查看登录保存的名称
    public static final String ChildAccountId = "ChildAccountId";//子账户id
    public static final String ChildAccountName = "ChildAccountName";//子账户名字



    private SPUtil spUtil;

    @Override
    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();
        spUtil = new SPUtil(getApplicationContext(), "fileName");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
            StrictMode.setVmPolicy(builder.build());
        }
        BaseApplication.NewToken = spUtil.getString(BaseApplication.TOKEN, "");

        if (spUtil.getInt(BaseApplication.MONEYKIND, 0) == 0)
        {
            spUtil.putInt(BaseApplication.MONEYKIND,1);
        }



    }


    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
